// 新增活动
import request from '@/utils/request'

export function uploadFile(data) {
  return request({
    url: '/common/upload/oss',
    method: 'post',
    data: data
  })
}

export function handerImg(e) {
  let type = 0
  let imgType = ['jpeg', 'png', 'tif']
  imgType.forEach((item) => {
    console.log('e' + e)
    console.log('item' + item)
    console.log(e.indexOf(item))
    if (e.indexOf(item) != -1) {
      type = 1
      return true
    }
  })
  if (type == 1) {
    return true
  } else {
    return false
  }

}

export  function handlerdata (array,datalist) {

  let result=[];
  if(!array||!datalist){
    return '';
  }
  if(array.length==0){
    return '';
  }
  if(datalist.length==0){
    return '';
  }
  array=array.split(",")
  for(var i=0;i<array.length;i++){
      var key=array[i];

      for(var j=0;j<datalist.length;j++){
        var data=datalist[j];

        if(key===data.dictValue){
          result.push(data.dictLabel);
        }
      }
  }
  return  result.join(",");
}
export  function handlergzdata (array,datalist) {

  let result=[];
  if(!array||!datalist){
    return '';
  }
  if(array.length==0){
    return '';
  }
  if(datalist.length==0){
    return '';
  }
  for(var i=0;i<array.length;i++){
    var key=array[i];
    for(var j=0;j<datalist.length;j++){
      var data=datalist[j];
      if(key==data.id){
        result.push(data.tablenumberId);
      }
    }
  }
  return  result.join(",");
}
